package engine;

import java.awt.Graphics2D;

import com.golden.gamedev.GameEngine;
import com.golden.gamedev.GameObject;
import com.golden.gamedev.object.Background;
import com.golden.gamedev.object.Sprite;
import com.golden.gamedev.object.background.ImageBackground;

public class EndLevel extends GameObject {

	private static final String LEVEL_COMPLETE = "resources/images/lev_comp.png";
	private static final String BACKGROUND_IMAGE = "resources/images/seagrass.jpg";
	
	Background myBackground;
	Sprite myComplete;
	private int myLevel;
	
	public EndLevel(GameEngine parent, int level) {
		super(parent);
		myLevel = level + 1;	
	}

	@Override
	public void initResources() {
		myBackground = new ImageBackground(getImage(BACKGROUND_IMAGE));
		myComplete = new Sprite(getImage(LEVEL_COMPLETE));
	}

	@Override
	public void render(Graphics2D g) {
		myBackground.render(g);
		myComplete.render(g);
	}

	@Override
	public void update(long elapsedTime) {
		myBackground.update(elapsedTime);
		myComplete.update(elapsedTime);
		if (click()){
			((BubblefishEngine) parent).setLevel(myLevel);
			parent.nextGameID=1;
			finish();
		}
	}

}
